file: bump sz_size to 64 bits
authorPaul Donald <[email protected]>
Tue, 2 Dec 2025 23:13:14 +0000 (00:13 +0100)
committerRobert Marko <[email protected]>
Wed, 3 Dec 2025 21:48:31 +0000 (22:48 +0100)
Some systems reveal /proc/kcore which for 64 bit systems has a size of

140,737,471,586,304 bytes.

This is a virtual mapping of the maximum possible RAM in a system. But if a 32
bit value tries to hold this, it is displayed as the erroneous value

-16,769,024 bytes

Bump the size to 64 bits to hold the correct value (and correct values for large
files).

Before this patch:

ubus call file list '{"path":"/proc"}'
...
{
"name": "kcore",
"type": "file",
"size": -16769024,
"mode": 33024,
"atime": 1764716086,
"mtime": 1764716086,
"ctime": 1764716086,
"inode": -268435271,
"uid": 0,
"gid": 0,
},
...

After this patch:

ubus call file list '{"path":"/proc"}'
...
{
"name": "kcore",
"type": "file",
"size": 140737471586304,
"mode": 33024,
"atime": 1764716086,
"mtime": 1764716086,
"ctime": 1764716086,
"inode": -268435271,
"uid": 0,
"gid": 0,
},
...

Tested on: OpenWrt SNAPSHOT r32139-1f879b8839 / 6.12.59
Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/rpcd/pull/22
Signed-off-by: Robert Marko <[email protected]>
file.c

diff --git a/file.c b/file.c
index 89ba6b4934d1383aca18fb5b405da381157d4a4c..591ab6bcfff327ebac3f59cfe889f7c8047a89cf 100644 (file)
--- a/file.c
+++ b/file.c
@@ -490,7 +490,7 @@ static void
 _rpc_file_add_stat(struct stat *s)
 {
        blobmsg_add_string(&buf, "type", d_types[_get_stat_type(s)]);
-       blobmsg_add_u32(&buf, "size",  s->st_size);
+       blobmsg_add_u64(&buf, "size",  s->st_size);
        blobmsg_add_u32(&buf, "mode",  s->st_mode);
        blobmsg_add_u32(&buf, "atime", s->st_atime);
        blobmsg_add_u32(&buf, "mtime", s->st_mtime);